Subject: AMAL-routine
From: Mikko Makela <[email-masked]>
To: [email-masked]
Date: Wed, 15 Sep 1993 20:48:22 +0300 (EET DST)

Quite many of you showed interest with this, so I'm sending
this to the list (it's < 2k).
I decided to make litle demonstration program out of it, just
to make it easier to understand.

--------------------cut here-------------------

'This is a small demo program to show, how to use AMAL's Move-command
'for (de)acceleration of objects.

'Programmed by Mikko Mdkeld

BALL=4 : Rem amount of balls
_TOPSPEED=200 : LOWEST_POSSIBLE_STEPCOUNT=4
'R2 must not > RB (topspeed) 
'RC will tell the lowest possible number of steps in movement. 
Amreg(1)=_TOPSPEED : Amreg(2)=LOWEST_POSSIBLE_STEPCOUNT

   'if ball hits the wall, main program will set R4=1, so 
   'that the Move command will be initiliazed.
A$="AUtotest (If R4=1 Jump Wall "
   'if ball must be stopped, R3 will be set to 1, and 
   'to continue the movement R3->2  
A$=A$+"If R3=1 Jump Hold ;If R3=2 Jump Go on "
   'R2 will be decreased every time the autotest is run, and
   'if it's <1, ball will be stopped. 
   'R2 is also used to count in how many steps will the movement be done. 
A$=A$+"If R2<1 Direct Owait else Let R2=R2-1 eXit "
A$=A$+"Wall:Let R4=0 Direct Begin "
A$=A$+"Hold:Direct Sleep; Go on:Let R3=0 Direct Begin)"
   'Here is the Move command
A$=A$+"Begin:If R2<1 Jump Owait; Move R0,R1,RC*RB/R2; Jump Begin "
A$=A$+"Sleep:Wait ;Owait: If R2>0 J Begin Pause J Owait "

'let's make an boject to move
Circle 100,100,7 : Paint 100,100 : Get Bob 0,1,90,90 To 111,111 : Cls 1

'init each ball
For L=0 To BALL-1
   Channel L To Bob L
   Bob L,80+L*15,80+L*15,1
   Amal L,A$
   Amreg(L,4)=1
Next L
'try different values for speed,range & angle
RSPEED=5000
RANGE=50
ANGLE#=3.3
For L=0 To BALL-1
   Amreg(L,0)=RANGE*Cos(ANGLE#-L*0.1) : Rem x-movemnt
   Amreg(L,1)=RANGE*Sin(ANGLE#-L*0.1) : Rem y-movement 
   Amreg(L,2)=RSPEED/RANGE+1 : Rem speed
   Amreg(L,3)=0 : Rem just to make sure
   Amreg(L,4)=1 : Rem to init movementsequence 
Next L

Synchro Off : Amal On 
Repeat 
   For L=0 To BALL-1
      'test for left screenborder
      If X Bob(L)<1
         Amreg(L,0)=-Amreg(L,0)
         Amreg(L,4)=1
         Bob L,0,,
      End If 
   Next L
   'try without wait! 
   Wait 2
   Synchro 
Until Amreg(0,2)<1
End